﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace QualitySupervision.Models
{
    public class ApiDBContent : DbContext
    {
        public ApiDBContent(DbContextOptions<ApiDBContent> options)
                : base(options)
        {
        }
        public DbSet<User> Users { get; set; }

        public DbSet<Menu> Menus { get; set; }
        public DbSet<Menu2> Menus2 { get; set; }
        public DbSet<League> Leagues { get; set; }
        public DbSet<Club> Clubs { get; set; }
        //public DbSet<Club2> Clubs2 { get; set; }
        public DbSet<Player> Players { get; set; }
        //public DbSet<StrategicTargetTask> StrategicTargetTasks { get; set; }
        //public DbSet<StrategicTargetOrganization> StrategicTargetOrganizations { get; set; }
        //public DbSet<StrategicTargetOrganization2> StrategicTargetOrganizations2 { get; set; }
        //public DbSet<StrategicTargetOrganizationDetail> StrategicTargetOrganizationDetails { get; set; }
        public DbSet<FileSystemItem> FileSystemItems { get; set; }
        public DbSet<Right> Rights { get; set; }
        public DbSet<role> roles { get; set; }
        public DbSet<Department> Departments { get; set; }
        public DbSet<Project> Projects { get; set; }
        public DbSet<Fujian> Fujians { get; set; }
        public DbSet<Contract> Contracts { get; set; }
        public DbSet<Message> Messages { get; set; }
        public DbSet<ProjectKindName> ProjectKindNames { get; set; }

        public DbSet<MobileAccrual> MobileAccruals { get; set; }

        //protected override void OnModelCreating(ModelBuilder modelBuilder)
        //{
        //    //设置联合主键
        //    //modelBuilder.Entity<GamePlayer>().HasKey(x => new { x.PlayerId, x.GameId });
        //    modelBuilder.Entity<Contract>()
        //        .HasOne(x => x.Project)//一个Resume拥有一个Player
        //        .WithOne()//每个Player又带了一个Resume
        //        .HasForeignKey("ProjectNo");
        //    //.HasForeignKey<Project>(x => x.MobileProjectNo);//Resume上又带了一个外键PlayerId
        //    //.HasConstraintName("ProjectNo")
        //}


        //public DbSet<Order> Orders { get; set; }
        //public DbSet<OrderDetail> OrderDetails { get; set; }


        //protected override void OnModelCreating(ModelBuilder modelBuilder)
        //{
        //    var b = modelBuilder.Entity<StrategicTargetOrganization>();
        //    b.HasOne(p => p.StrategicTargetTask)
        //      .WithMany(p => p.AppraiseUnits)
        //      .IsRequired()
        //      .HasForeignKey(p => p.StrategicTargetTaskID);
        //modelBuilder.Entity<StrategicTargetOrganization>().WillCascadeOnDelete(true);
        //modelBuilder.Entity<StrategicTargetTask>().HasMany<StrategicTargetOrganization>(f => f.AppraiseUnits).WithOne(f => f.ID).HasOne(f => f).WithMany().OnDelete(DeleteBehavior.Cascade);


        //modelBuilder.Entity<StrategicTargetTask>().HasMany(b => b.AppraiseUnits).WithOne(p => p.State)
        //    .HasForeignKey(p => p.ID)
        //    .OnDelete(DeleteBehavior.Cascade);
        //    modelBuilder.Entity<Blog>().HasMany(b => b.Posts).WithOne(p => p.Blog)
        //        .HasForeignKey(p => p.BlogId)
        //        .OnDelete(DeleteBehavior.Cascade);

        //modelBuilder.Entity<Post>().HasOne(p => p.Blog).WithMany(b => b.Posts)
        //    .HasForeignKey(p => p.BlogId)
        //    .OnDelete(DeleteBehavior.Cascade);
        //}
    }
}
